﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Arizu.Repository;
using System.Data;

namespace AiRiZu.User
{
    public partial class MyVouchers : Common
    {
        public double BRegist { get; set; }
        public double BUploadImg { get; set; }
        public double BRegistFriand { get; set; }
        public double BFirstHire { get; set; }
        public double BReserveFriand { get; set; }
        public double BGiftAfterOrder { get; set; }
        public double BQuestionnaire { get; set; }

        public double BTotal { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["logId"] == null)
            {
                return;
            }

            Vouchers vouchers = Vouchers.CreateInstance();
            DataTable dt = vouchers.GetVouchers(int.Parse(Session["logId"].ToString()));

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    switch (int.Parse(dt.Rows[i]["Type"].ToString()))
                    {
                        case (int)VirtualCurrencyType.BFirstHire:
                            BFirstHire += Math.Round(float.Parse(dt.Rows[i]["Value"].ToString()), 1);
                            break;
                        case (int)VirtualCurrencyType.BGiftAfterOrder:
                            BGiftAfterOrder += Math.Round(float.Parse(dt.Rows[i]["Value"].ToString()), 1);
                            break;
                        case (int)VirtualCurrencyType.BQuestionnaire:
                            BQuestionnaire += Math.Round(float.Parse(dt.Rows[i]["Value"].ToString()), 1);
                            break;
                        case (int)VirtualCurrencyType.BRegist:
                            BRegist += Math.Round(float.Parse(dt.Rows[i]["Value"].ToString()), 1);
                            break;
                        case (int)VirtualCurrencyType.BRegistFriand:
                            BRegistFriand += Math.Round(float.Parse(dt.Rows[i]["Value"].ToString()), 1);
                            break;
                        case (int)VirtualCurrencyType.BReserveFriand:
                            BReserveFriand += Math.Round(float.Parse(dt.Rows[i]["Value"].ToString()), 1);
                            break;
                        case (int)VirtualCurrencyType.BUploadImg:
                            BUploadImg += Math.Round(float.Parse(dt.Rows[i]["Value"].ToString()), 1);
                            break;
                        default:
                            break;
                    }
                }

                BTotal = BFirstHire + BGiftAfterOrder + BQuestionnaire + BRegist + BRegistFriand + BReserveFriand + BUploadImg;

            }
        }
    }
}
